#ifndef CFOURIERTRANSFORM_H
#define CFOURIERTRANSFORM_H
#include <QImage>
#include "Helper.h"

#define m_f2Pi 3.14159265 * 2.0
#define m_fSqrt2 sqrt(2)

class CFourierTransform
{

public:
    int                 m_Width;
    int                 m_Height;
    float               **m_FourierPhase;
    float               **m_FourierPhaseR;
    float               **m_FourierPhaseG;
    float               **m_FourierPhaseB;

    // For testing
    Complex             **m_TestFFTData;
    Complex             **fft;
    Complex             **fftR;
    Complex             **fftG;
    Complex             **fftB;
    //Complex             **shiftedFFT;
    //Complex             **shiftedFFTR;
    //Complex             **shiftedFFTG;
    //Complex             **shiftedFFTB;
    Complex             **forIFFT;
    Complex             **forIFFTR;
    Complex             **forIFFTG;
    Complex             **forIFFTB;
    Complex             **m_ppW;
    int                 m_iN;

private:
    QImage              *m_Data;
    QImage              *m_ImgData;

    QImage              *input;
    QImage              *output;

public:
    CFourierTransform() {}
    //CFourierTransform(QImage *img);
    CFourierTransform(int _w, int _h): m_Width(_w), m_Height(_h) {m_Data = NULL, m_ImgData = NULL;  }
    QImage              *GetData() const;
    QImage              *GetDataData();
    void                SetData(QImage*);
    QImage              *FFT2Img(Complex**, bool);
    QImage              *FFT2ImgRGB(Complex**,Complex**,Complex**, bool);
    QImage              *PhaseMod2Img(float**);
    uint                Val2Col(int);
    uint                Val2ColRGB(int,int,int);

    // Test and debug purpose methods:
    void                FillTestFFTData();

    QImage              *GetImg() const;
    void    ImgToComplex();
    void    ImgOutToComplex();
    void    ImgToComplexRGB();
    void    FFT();
    void    IFFT();
    void    FFT2D(Complex**, int);
    //void    FFT2DNew(Complex**, int);
    void    FFT1D(int, int, int, Complex *);
    //void    FFT1DNew(Complex*, Complex*, int, int);
    Complex**    ShiftFFT(Complex**);
    //Complex**    ShiftFFTRGB(Complex**, char);
    //void    SymetricFFT();
    bool    IsGrey();

private:

};

#endif // CFOURIERTRANSFORM_H
